#include "test_list_view.h"
#include "ui_test_list_view.h"
#include "widget_test_list_view.h"
#include "widget_student_new_midterm.h"
#include "widget_view_button.h"
#include "widget_newtest_button.h"
#include "widget_teacher_list_view.h"
#include "widget_create_test.h"
#include "widget_viewupdown_button.h"
#include "widget_header_buttons.h"
#include <iostream>


test_list_view::test_list_view(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::test_list_view)
{
    setMainWindowTitle("Test List");
    ui->setupUi(this);
    ui->gridLayout_5->addWidget(new widget_header_buttons(this),0,0,0,0);

    if(g_currentSession == STUDENT_SESSION){
        widget_view_button* vButton;
        widget_newtest_button* vButtoni;
        widget_test_list_view* vButtonj;
        vButton = new widget_view_button(this);
        vButtoni = new widget_newtest_button(this);
        vButtonj = new widget_test_list_view(this);
        ui->gridLayout->addWidget(vButtonj,0,0);
        ui->gridLayout_2->addWidget(vButton,0,0);
        ui->gridLayout_3->addWidget(new widget_student_new_midterm(this),0,0);
        ui->gridLayout_4->addWidget(vButtoni,0,0);
        //connect(vButton->getViewtestButton(), SIGNAL(clicked()), this, SLOT(onviewtestClicked()));
        connect(vButton->getSectionButton(), SIGNAL(clicked()), this, SLOT(onviewtestClicked()));
        connect(vButtoni->getNewtestButton(), SIGNAL(clicked()), this, SLOT(onviewtestClicked()));

    }
    else if(g_currentSession == TEACHER_SESSION){
        widget_viewupdown_button* tButton;
        widget_create_test* cButton;
        tButton = new widget_viewupdown_button(this);
        cButton = new widget_create_test;
        ui->gridLayout->addWidget(new widget_teacher_list_view(this),0,0);
        ui->gridLayout_2->addWidget(tButton,0,0);
        ui->gridLayout_3->addWidget(cButton,0,0);
        connect(tButton->getTeacherviewButton(), SIGNAL(clicked()), this, SLOT(onviewtestClicked()));
        connect(tButton->getTeacherview2Button(), SIGNAL(clicked()), this, SLOT(onviewtestClicked()));
        connect(cButton->getCreatetestButton(), SIGNAL(clicked()), this, SLOT(onviewtestClicked()));
    }
}

test_list_view::~test_list_view()
{
    delete ui;
}

/*
void test_list_view::on_pushButton_clicked()
{
    emit (changeScene(SIGN_IN_VIEW));
}

void test_list_view::on_studentlistlink_clicked()
{
    emit (changeScene(STUDENT_LIST_VIEW));
}
*/

void test_list_view::onviewtestClicked()
{
    emit changeScene(TEST_VIEW);
}
